package com.superb.system.api.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.superb.system.api.dto.MenuItem;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.baomidou.mybatisplus.annotation.TableName;
import com.superb.common.database.entity.BaseEntity;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 系统菜单权限表
 * @Author: ajie
 * @CreateTime: 2024-5-15
 */
@Data
@TableName("system_permission")
@Tag(name = "系统菜单权限表")
@EqualsAndHashCode(callSuper=false)
public class SystemPermission extends BaseEntity {

    @NotNull(message = "菜单类型不能为空")
    @Schema(title = "菜单类型", description = "0系统菜单；1顶部菜单；2中台菜单", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer type;

    @NotNull(message = "菜单属性不能为空")
    @Schema(title = "菜单属性", description = "0父级菜单；1子菜单；2权限", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer menuType;

    @NotBlank(message = "名称不能为空")
    @Schema(title = "名称", description = "菜单和权限名称", requiredMode = Schema.RequiredMode.REQUIRED)
    private String name;

    @Schema(description = "菜单路由")
    private String path;

    @Schema(description = "组件名称")
    private String component;

    @Schema(description = "权限代码")
    private String perms;

    @Schema(description = "菜单图标")
    private String icon;

    @Schema(description = "父级菜单id")
    private String parentId;

    @Schema(title = "外链", description = "0否；1是")
    private Integer outerChain;

    @Schema(title = "状态", description = "0启用；1禁用")
    private Integer status;

    @NotNull(message = "排序不能为空")
    @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer sort;

    @Schema(title = "子菜单")
    @TableField(exist = false)
    private List<SystemPermission> children;

    @Schema(title = "权限集合", hidden = true)
    @TableField(exist = false)
    private List<SystemPermission> permissions;

    /**
     * 权限和菜单不存在部门-需要分配关联
     */
    @Schema(hidden = true)
    @TableField(exist = false, fill = FieldFill.DEFAULT)
    private String organId;
}